package com.ultrawise.survey.common.utils;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

import com.ultrawise.survey.contants.SurveyConstants;
import com.ultrawise.survey.module.surevybase.vo.TSurveyInfoBase;

public class Testmain {

	private String[] getFiledName(Object o) {
		try {
			Field[] fields = o.getClass().getDeclaredFields();
			String[] fieldNames = new String[fields.length];
			for (int i = 0; i < fields.length; i++) {
				fieldNames[i] = fields[i].getName();
				System.out.println(fields[i].getName());

				System.out.println(getFieldValueByName(fieldNames[i], o));

			}
			return fieldNames;
		} catch (SecurityException e) {
			e.printStackTrace();
			System.out.println(e.toString());
		}
		return null;
	}

	private Object getFieldValueByName(String fieldName, Object o) {
		try {
			String firstLetter = fieldName.substring(0, 1).toUpperCase();
			String getter = "get" + firstLetter + fieldName.substring(1);
			Method method = o.getClass().getMethod(getter, new Class[] {});
			Object value = method.invoke(o, new Object[] {});
			return value;
		} catch (Exception e) {
			System.out.println("属性不存在");
			return null;
		}
	}

	public static void main(String[] args) {
		Testmain tm = new Testmain();
		// TSurveyInfoBase tb = new TSurveyInfoBase();
		// tb.setId(111);
		// tm.getFiledName(tb);
		String tr = "sdfs|dfsdd爱上对|方是大方sdf";
		String[] spst= tr.split(SurveyConstants.SURVEY_DATAINFO_SPACE);
		System.out.println(spst);
	}
}
